package com.gxa.www.cl.service.impl;

import com.gxa.www.cl.domain.vo.Person;
import com.gxa.www.cl.mapper.PurchaseMapper; // 确保导入正确的 PurchaseMapper
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
public class PurchaseServiceImpl implements com.gxa.www.cl.service.PurchaseService {

    @Autowired
    private PurchaseMapper purchaseMapper;

    @Transactional // 添加事务注解
    public void addPurchase(Map<String, Object> formData) {
        // 确保 category 字段不为 null
        if (formData.get("category") == null) {
            formData.put("category", "默认分类"); // 设置默认分类
        }
        purchaseMapper.insertPurchase(formData);
    }

    @Override
    public List<Person> queryCaiName() {
        return purchaseMapper.queryCaiName();
    }
}
